package com.xx.springboot.DataStructure.LeetCode.String;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by xiaoxiunique on 2018-11-12.
 */
public class canConstruct {
    public boolean canConstruct(String ransomNote, String magazine) {
        int[] arr = new int[26];

        for (int i = 0 ; i < magazine.length() ; i ++) {
            arr[magazine.charAt(i) - 'a'] ++;
        }

        for (int j = 0 ; j < ransomNote.length() ; j ++) {
            if(--arr[ransomNote.charAt(j)] < 0){
                return false;
            }
        }
        return true;
    }


}
